import http from '../utils/Http'
import validate from '../utils/Validate'

//接口API统一
export default class api {


    static apiAccountLogin(username,password,code) {
        return http.get('miniApi/v1/login/accountLogin?username='+username+"&password="+password+"&code="+code).then(resp => resp)
    }
    //微信登录后台获取微信openID
    static apiWecahtLogin(code) {
      return http.get('miniApi/v1/login/login?code='+code).then(resp => resp)
    }
    //微信获得用户信息
    static apiWechatInfo(param) {
      return http.post('miniApi/v1/login/initUser',param).then(resp => resp)
    }
    //获取用户信息
    static apiGetUserInfo(userId='') {
      return http.get('miniApi/v1/user/info?userId='+userId).then(resp => resp)
    }
    //更改上下班状态
    static apiUpdateOnline(param) {
        return http.post('miniApi/v1/user/updateOnline/'+param.userId,param).then(resp => resp)
    }

    //首页获取产品列表,页码从1开始
    static apiGetMessageList(page){
      return http.get('miniApi/v1/notices/infoList?page='+page).then(resp=>resp)
    }
    //首页到期提醒消息列表
    static apiGetIndexMessageList(page){
      return http.get('miniApi/v1/notices/expiredList?page='+page).then(resp=>resp)
    }
    static apiGetMessageDetail(id){
      return http.get('miniApi/v1/notices/'+id).then(resp=>resp)
    }
    //获取场地预定列表
    static apiGetFieldOrderList(areaId,page){
      return http.get('miniApi/v1/fields/list?areaId='+areaId+'&page='+page).then(resp=>resp)
    }
    //获取场地预定详情  根据核销码查询
    static apiGetFieldBookByCode(code){
        return http.get('miniApi/v1/fields/getFieldBookByCode/'+code).then(resp=>resp)
    }
    static apiGetFieldBookDeatil(id){
        return http.get('miniApi/v1/fields/getFieldBookDetail/'+id).then(resp=>resp)
    }
    //获取场地预定列表
    static apiPostCheckCode(params,page){
      return http.get('miniApi/v1/fields/checkCode',params).then(resp=>resp)
    }
    //获取场地区域列表
    static apiGetFieldAreaList(){
        return http.get('miniApi/v1/fields/areaList').then(resp=>resp)
    }
    //离场
    static apiLeaveField(id,formId){
        return http.get('miniApi/v1/fields/leaveField/'+id+'?formId='+formId).then(resp=>resp)
    }

}
